package com.raymond.httpclient;

import java.util.concurrent.*;

/**
 * 线程池配置信息
 * @author :  raymond
 * @version :  V1.0
 * @date :  2021-03-30 12:05
 */
public class ThreadPoolConfig {
    private int corePoolSize = 20;

    private int maximumPoolSize = 20;

    private long keepAliveTime = 1;

    private TimeUnit unit = TimeUnit.MINUTES;

    private BlockingQueue<Runnable> workQueue = new LinkedBlockingDeque<Runnable>();

    private ThreadFactory threadFactory = new ThreadFactory() {
        @Override
        public Thread newThread(Runnable r) {
            Thread thread = new Thread(r);
            thread.setName("http-" + thread.getId());
            thread.setDaemon(true);
            return thread;
        }
    };

    private RejectedExecutionHandler handler = new ThreadPoolExecutor.CallerRunsPolicy();

    int getCorePoolSize() {
        return corePoolSize;
    }

    public void setCorePoolSize(int corePoolSize) {
        this.corePoolSize = corePoolSize;
    }

    int getMaximumPoolSize() {
        return maximumPoolSize;
    }

    public void setMaximumPoolSize(int maximumPoolSize) {
        this.maximumPoolSize = maximumPoolSize;
    }

    long getKeepAliveTime() {
        return keepAliveTime;
    }

    public void setKeepAliveTime(long keepAliveTime) {
        this.keepAliveTime = keepAliveTime;
    }

    TimeUnit getUnit() {
        return unit;
    }

    public void setUnit(TimeUnit unit) {
        this.unit = unit;
    }

    BlockingQueue<Runnable> getWorkQueue() {
        return workQueue;
    }

    public void setWorkQueue(BlockingQueue<Runnable> workQueue) {
        this.workQueue = workQueue;
    }

    ThreadFactory getThreadFactory() {
        return threadFactory;
    }

    public void setThreadFactory(ThreadFactory threadFactory) {
        this.threadFactory = threadFactory;
    }

    RejectedExecutionHandler getHandler() {
        return handler;
    }

    public void setHandler(RejectedExecutionHandler handler) {
        this.handler = handler;
    }
}
